Micron Document
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| SparkN0de-git | SparkN0de |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Commit 978800aaf9dc6afb5233c38c3e21406082f2db9d


Parents : 8a35afb
Author : Mark Qvist <mark@adepta.io>
Date : 2018-04-26T10:34:39+02:00

Added KISS flow control

Changes

4 files changed, 24 insertions(+), 0 deletions(-)

M Config.h +7
M Framing.h +1

Diff

diff --git a/Config.h b/Config.h
index a7e02e0..812a319 100644
--- a/Config.h
+++ b/Config.h
@@ -26,6 +26,9 @@
const int pin_dio = 2;
const int pin_led_rx = 5;
const int pin_led_tx = 4;
+
+ #define FLOW_CONTROL_ENABLED true
+ #define QUEUE_SIZE 0
#endif
#if MCU_VARIANT == MCU_1284P
@@ -34,6 +37,9 @@
const int pin_dio = 2;
const int pin_led_rx = 12;
const int pin_led_tx = 13;
+
+ #define FLOW_CONTROL_ENABLED true
+ #define QUEUE_SIZE 24
#endif
// MCU independent configuration parameters
@@ -42,6 +48,7 @@
// Default LoRa settings
int lora_sf = 0;
+ int lora_cr = 5;
int lora_txp = 0xFF;
uint32_t lora_bw = 0;
uint32_t lora_freq = 0;

diff --git a/Framing.h b/Framing.h
index 4c0efe4..6b00cc4 100644
--- a/Framing.h
+++ b/Framing.h
@@ -14,6 +14,7 @@
#define CMD_SF 0x04
#define CMD_RADIO_STATE 0x05
#define CMD_RADIO_LOCK 0x06
+ #define CMD_READY 0x0F
#define CMD_STAT_RX 0x21
#define CMD_STAT_TX 0x22

diff --git a/RNode_Firmware.ino b/RNode_Firmware.ino
index e00c160..65eb3b0 100644
--- a/RNode_Firmware.ino
+++ b/RNode_Firmware.ino
@@ -42,6 +42,7 @@ bool startRadio() {
setTXPower();
setBandwidth();
setSpreadingFactor();
+ setCodingRate();
getFrequency();
LoRa.enableCrc();
@@ -178,6 +179,10 @@ void transmit(size_t size) {
LoRa.endPacket();
led_tx_off();
LoRa.receive();
+
+ if (FLOW_CONTROL_ENABLED)
+ kiss_indicate_ready();
+
} else {
kiss_indicate_error(ERROR_TXFAILED);
led_indicate_error(5);

diff --git a/Utilities.cpp b/Utilities.cpp
index ec09a84..533445c 100644
--- a/Utilities.cpp
+++ b/Utilities.cpp
@@ -146,6 +146,13 @@ void kiss_indicate_random(uint8_t byte) {
Serial.write(FEND);
}
+void kiss_indicate_ready() {
+ Serial.write(FEND);
+ Serial.write(CMD_READY);
+ Serial.write(0x01);
+ Serial.write(FEND);
+}
+
bool isSplitPacket(uint8_t header) {
return (header & FLAG_SPLIT);
}
@@ -165,6 +172,10 @@ void setSpreadingFactor() {
if (radio_online) LoRa.setSpreadingFactor(lora_sf);
}
+void setCodingRate() {
+ if (radio_online) LoRa.setCodingRate4(lora_cr);
+}
+
void setTXPower() {
if (radio_online) LoRa.setTxPower(lora_txp);
}


──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────